﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Composite.Regions;
using Microsoft.Practices.Unity;
using TelecoSystems.Infrastructure;
using TelecoSystems.Modules.Products.ViewModels;

namespace TelecoSystems.Modules.Products.Views
{
    public partial class ProductsReportsView : UserControl
    {
        IRegionManager regionManager;
        IUnityContainer unityContainer;

        public ProductsReportsView(ProductsReportsViewModel _viewModel, IRegionManager _regionManager, IUnityContainer _unityContainer)
        {
            InitializeComponent();

            DataContext = _viewModel;

            regionManager = _regionManager;
            unityContainer = _unityContainer;
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ProductsBrowseView view = this.unityContainer.Resolve<ProductsBrowseView>();
            IRegion mainRegion = regionManager.Regions[RegionNames.MainRegion];
            if (!mainRegion.Views.Contains(view))
            {
                mainRegion.Add(view);
            }
            mainRegion.Activate(view);
        }
    }
}
